goFS() {
    let arr = [{ role: "user", content: this.textarea2 }]
    console.log(this.textarea2)
    let body = JSON.parse(JSON.stringify(this.opstions))
    body.messages = arr
    this.isDialogue = true;

    let time = this.$moment().format('YYYY-MM-DD HH:mm:ss')
    // console.log(time)
    let obj = { type: 1, text: this.textarea2, date: time }
    this.textList.push(obj)
    this.text = ''
    // console.log(gofun)
    this.gofun(body)
},
//发送网络请求
async gofun(body) {
    this.controller = new AbortController();
    const signal = this.controller.signal;
    const options = {
        method: 'POST',
        headers: { Authorization: `Bearer ${this.token}`, 'Content-Type': 'application/json' },
        body: JSON.stringify(body),
        signal
    };
    let time = this.$moment().format('YYYY-MM-DD HH:mm:ss')
    // console.log(time)

    let obj = { type: 0, text: '', date: time }
    this.textList.push(obj)

    const response = await fetch(this.bastDMXUrl, options)
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
    const reader = response.body.getReader();
    const decoder = new TextDecoder();
    let partialData = '';

    while (this.isDialogue) {
        const { done, value } = await reader.read();
        if (done) break;

        const chunk = decoder.decode(value, { stream: true });
        partialData += chunk;

        // 处理可能的多条消息（按换行符分割）
        const lines = partialData.split('\n');
        partialData = lines.pop() || ''; // 保留未完成的行

        for (const line of lines) {
            if (line.trim()) {
                if (line.startsWith('data: ')) {
                    try {
                        let data = this.goIsEnd(line.slice(6))
                        if (JSON.stringify(data) !== '{}' && data.choices[0].delta) {
                            console.log('----->', data.choices[0].delta)
                            let txt = data.choices[0].delta.content
                            if (txt) {
                                obj.text = obj.text + txt
                                // this.$set(obj,"text",obj.text)
                            }

                        } else {
                            //关闭循环
                            this.isDialogue = false
                        }

                    } catch (e) {
                        console.error('解析错误:', e);
                    }
                }
            }
        }
    }
},
//取消网络请求
goSignal() {
    console.log(this.controller)
    if (this.controller) {
        try {
            this.controller.abort();
        } catch (e) {
            console.log(e)
        }
    }
    this.controller = null
    this.isDialogue = false

},
// 判断字符串是否结束
goIsEnd(ele) {
    if (ele === '[DONE]') {
        return {}
    } else {
        return JSON.parse(ele)
    }
},
//节流函数
goAntiShake(ss, cd) {
    if (!this.time) {
        this.time = setTimeout(() => {
            cd()
            this.time = null
        }, ss)
    }

}